﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms;

//namespace ClientProject
//{
//    static class Program
//    {
//        /// <summary>
//        /// 应用程序的主入口点。
//        /// </summary>
//        [STAThread]
//        static void Main()
//        {
//            Application.EnableVisualStyles();
//            Application.SetCompatibleTextRenderingDefault(false);
//            if (System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Process.GetCurrentProcess().ProcessName).Length > 1)
//            {
//                Application.Exit();
//            }
//            else
//            {
//                Application.Run(new FrmClient());
//            }
//        }
//    }
//}

namespace ClientProject
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            //Get   the   running   instance.   

            Process instance = null;
            //Process instance = Common.AppInstance.RunningInstance(Assembly.GetExecutingAssembly().Location.Replace("/", "\\"));
            if (instance == null)
            {
                System.Windows.Forms.Application.EnableVisualStyles();   //这两行实现   XP   可视风格   
                System.Windows.Forms.Application.DoEvents();
                //There   isn't   another   instance,   show   our   form.   
                System.Windows.Forms.Application.Run(new FrmClient());
            }
            else
            {
                //There   is   another   instance   of   this   process.   
                Common.AppInstance.HandleRunningInstance(instance);
            }
        }

    }
}
